﻿<UserControl x:Class="SLExtensions.Showcase.PageLayers"
    xmlns="http://schemas.microsoft.com/client/2007" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:SLExtensions.Showcase;assembly=SLExtensions.Showcase"
    xmlns:vemap="clr-namespace:SLExtensions.Controls.Layers.VirtualEarth;assembly=SLExtensions.Controls"
    xmlns:gmap="clr-namespace:SLExtensions.Controls.Layers.GoogleMaps;assembly=SLExtensions.Controls"
    xmlns:map="clr-namespace:SLExtensions.Controls.Layers;assembly=SLExtensions.Controls"
    xmlns:mapproj="clr-namespace:SLExtensions.Controls.Layers.MapProjections;assembly=SLExtensions.Controls"
    MinWidth="300" MinHeight="300"
    >
    <UserControl.Resources>
        <local:TestData x:Name="datasource" />
        <map:GPSLatitudeToMapConverter x:Name="latConverter"/>
        <map:GPSLongitudeToMapConverter x:Name="lonConverter"/>
        <mapproj:MercatorProjection x:Name="mercator" />

        <DataTemplate x:Name="itemTemplate">
            <map:LayerItem Canvas.Left="{Binding Path=GPSPoint.X, Converter={StaticResource lonConverter}, ConverterParameter={StaticResource mercator}}" 
                           Canvas.Top="{Binding Path=GPSPoint.Y, Converter={StaticResource latConverter}, ConverterParameter={StaticResource mercator}}" >
                <map:LayerItem.Template>
                    <ControlTemplate TargetType="map:LayerItem">
                        <Canvas x:Name="RootElement" Background="Transparent" >
                          

                            <Path Height="12" Width="12" Canvas.Left="-6" Canvas.Top="-12" Stroke="#FF000000" Data="M0,0 L14,0 L7,20 z" Fill="Yellow" Stretch="Fill">
                            </Path>
                            <Path Height="12" Width="12" Canvas.Left="-6" Data="M0,0 L14,0 L7,-20 z" Stretch="Fill" >
                                <Path.Fill>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FF000000"/>
                                        <GradientStop Color="#00000000" Offset="0.8"/>
                                    </LinearGradientBrush>
                                </Path.Fill>
                            </Path>
                        </Canvas>
                    </ControlTemplate>
                </map:LayerItem.Template>
            </map:LayerItem>
        </DataTemplate>

    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" VerticalAlignment="Top" >
            <Button Height="30" Click="Button_Click" Content="Change view"/>
            <Grid Background="#80FFFFFF">
                <TextBlock x:Name="viewName"/>
            </Grid>
            <Button Click="btnItems_Click" Content="Add point"/>
            <Button x:Name="zoomOut" Content="Zoom out" Click="zoomOut_Click"/>
            <Button x:Name="zoomIn" Content="Zoom in" Click="zoomIn_Click"/>
            <Button x:Name="moveRight" Content="Move right" Click="moveRight_Click"/>
        </StackPanel>
        <Grid Grid.Row="1">
            <map:LayerHost x:Name="map" Zoom="1">
                <map:LayerHost.LayerDefinitions>
                    <map:LayerDefinition LayerName="tilesLayer" />
                    <map:LayerDefinition LayerName="pointsLayer" />
                </map:LayerHost.LayerDefinitions>
                <map:LayerSource ItemsSource="{Binding Path=Data, Source={StaticResource datasource}}" ItemTemplate="{StaticResource itemTemplate}" map:LayerHost.Layer="pointsLayer" >
                </map:LayerSource>
            </map:LayerHost>

            <Rectangle Stroke="Red" StrokeThickness="1" Visibility="Collapsed"/>
        </Grid>

    </Grid>
</UserControl>
